package com.tao.media.api;

import com.tao.base.model.PageParams;
import com.tao.base.model.PageResult;
import com.tao.base.model.Result;
import com.tao.media.domain.dto.QueryMediaParamsDto;
import com.tao.media.domain.pojo.MediaFiles;
import com.tao.media.domain.vo.UploadFilesVo;
import com.tao.media.service.impl.MediaFilesServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 媒资管理接口
 * </p>
 *
 * @author taohongrun
 * @since 2024/11/7
 */
@RestController
@RequiredArgsConstructor
@Tag(name = "媒资管理接口",description = "管理媒资内容")
@RequestMapping("")
@Slf4j
public class MediaController {

    final MediaFilesServiceImpl mediaFilesService;
    @Operation(description = "媒资列表查询接口")
    @PostMapping("/files")
    public Result<PageResult<MediaFiles>> list(PageParams pageParams, @RequestBody QueryMediaParamsDto queryMediaParamsDto){
        Long companyId = 1232141425L;
        return Result.success(mediaFilesService.queryMediaFiels(companyId,pageParams,queryMediaParamsDto));
    }

    @Operation(description = "上传图片")
    @PostMapping(value = "/upload/coursefile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Result<UploadFilesVo> uploadFiles(@RequestPart("file") MultipartFile file,String htmlObject) throws Exception {
        return Result.success(mediaFilesService.uploadFiles(1232141425L,file,htmlObject));
    }


}
